package com.mqz.zebraEcommerce.commodity.controller;

import java.util.Arrays;
import java.util.Map;

import com.mqz.zebraEcommerce.commodity.service.ProductBaseAttrValueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.mqz.zebraEcommerce.commodity.entity.ProductBaseAttrValueEntity;
import com.mqz.zebraEcommerce.common.utils.PageUtils;
import com.mqz.zebraEcommerce.common.utils.R;


/**
 * 商品SPU基本属性表
 *
 * @author mqz
 * @email 952905931@qq.com
 * @date 2025-03-07 18:55:44
 */
@RestController
@RequestMapping("commodity/productBaseAttrValue")
public class ProductBaseAttrValueController {
    @Autowired
    private ProductBaseAttrValueService productBaseAttrValueService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = productBaseAttrValueService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id) {
        ProductBaseAttrValueEntity productBaseAttrValue = productBaseAttrValueService.getById(id);

        return R.ok().put("productBaseAttrValue", productBaseAttrValue);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ProductBaseAttrValueEntity productBaseAttrValue) {
        productBaseAttrValueService.save(productBaseAttrValue);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ProductBaseAttrValueEntity productBaseAttrValue) {
        productBaseAttrValueService.updateById(productBaseAttrValue);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        productBaseAttrValueService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
